package cn.jichangxiu.common.web.model.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

@Data
@ToString
@NoArgsConstructor
@ApiModel("通用返回结果对象")
public class ResponseResult {

    @ApiModelProperty("操作是否成功")
    boolean success;

    @ApiModelProperty("操作代码")
    int code;

    @ApiModelProperty("提示信息")
    String message;

    public ResponseResult(ResultCode resultCode){
        this.success = resultCode.success();
        this.code = resultCode.code();
        this.message = resultCode.message();
    }

    public static ResponseResult SUCCESS(){
        return new ResponseResult(ResponseCode.SUCCESS);
    }

    public static ResponseResult FAIL(){
        return new ResponseResult(ResponseCode.FAIL);
    }

}
